/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.geaSV.busquedas;

import com.geaSV.conexiones.conectarBD;
import com.geaSV.entities.PersonaE;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author vash
 */
public class busquedaCliente {
    private Connection conx = null;
    private Statement sttm;
    private ResultSet rs;
    
    public PersonaE  buscarCliente(String dui) throws SQLException{
    // esto es instansiar el objeto     
   PersonaE P = new PersonaE();
    try{
        
        conx = conectarBD.conectar();
        sttm = conx.createStatement();
        
        rs = sttm.executeQuery("SELECT * from persona where dui='"+dui+"'");
        while(rs.next()){
           
            P.setId(rs.getInt("id"));   
            P.setNombre1(rs.getString("nombre1"));
            P.setNombre2(rs.getString("nombre2"));
            P.setApel1(rs.getString("apellido1"));
            P.setApel2(rs.getString("apellido2"));
            P.setDireccion(rs.getString("direccion"));
            P.setEmail(rs.getString("email"));
            P.setTelefono(rs.getString("telefono"));
            P.setNit(rs.getString("nit"));
            P.setId(rs.getInt("id"));
             
        }
        
    }catch(Exception e){

        System.out.println("esto paso"+e.getMessage());
      
    }finally{
        rs.close();
        sttm.close();
        conx.close();
        return P; 
    }
}
}